﻿if exists(select * from sysobjects where name = 'ERPStoreOffersOfferedProduct') 
Begin
	drop view dbo.ERPStoreOffersOfferedProduct
End
Go

Create view dbo.ERPStoreOffersOfferedProduct
As
Select 
EntitySelectionDetail.Id as Id
, InternalEntityId as ProductId
, EntitySelectionDetail.EntitySelectionId as SelectionId
From EntitySelection
		join EntitySelectionDetail on EntitySelection.Id = EntitySelectionDetail.EntitySelectionId
where EntitySelection.EntityNameBase = 'Product'
Go
